package com.shopping.dao.Impl;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.shopping.model.Users;

@Repository
public interface IUsersDao {


    /**
     * 分页查询客户信息
     */
    @Select("select count(*) from users")
    Integer selUserscount();
    @Select("select*from users limit #{offset},#{size}")
    List<Users> selUser(@Param("offset")Integer offset,@Param("size")Integer size);
    

	@Select("select * from users where id = #{userId}")
	Users getById(int userId);
    
    /**
     * 添加客户信息
     */
    @Insert("insert into users values(null,#{username},#{password},#{name},#{phone},#{address})")
    Integer addUsers(Users user);
    
    /**
     * 重置用户密码
     */
    @Select("select*from users where id=#{id}")
    Users selByIdUser(Integer id);
    @Update("update users set password=#{password} where id=#{id}")
    Integer editUserPwd(@Param("password")Integer password,@Param("id")Integer id);
    
    /**
     * 修改客户信息
     */
    @Update("update users set name=#{name},phone=#{phone},address=#{address} where id=#{id}")
    Integer editUsers(Users user);
    
    /**
     * 删除客户
     */
    @Delete("delete from users where id=#{id}")
    Integer delUsers(Integer id);
    
}
